const { static } = require("express");
module.exports = class User extends require("./model") {
    // 获取指定用户的个人日记
  static getPersinal(user_id) {
    console.log(user_id);
    return new Promise((resolve, reject) => {
      let sql = "SELECT * FROM persinal WHERE user_id = ? ORDER BY TIME DESC";
      this.query(sql, user_id)
        .then((res) => {
          resolve(res);
        })
        .catch((err) => {
          console.log(`获取个人日记失败：${err.message}`);
          reject(err);
        });
    });
  }
  static delArticle(id) {
    return new Promise((resolve, reject) => {
      let sql = "DELETE FROM article WHERE id = ?";
      this.query(sql, id)
        .then((res) => {
          resolve(res.affectedRows);
        })
        .catch((err) => {
          console.log(`删除文章失败：${err.message}`);
          reject(err);
        });
    });
  }
};
